from odoo import fields, models, api, _
from odoo.exceptions import ValidationError


class MakeupSetting(models.Model):
    _name = 's.makeup.product'
    _description = 'makeup setting'

    origin_product_tmpl_id = fields.Many2one('product.template', required=True)
    product_id = fields.Many2one('product.product', required=True)

    @api.constrains('product_id')
    def constrains_product_id(self):
        for rec in self:
            if rec.origin_product_tmpl_id and rec.product_id and rec.product_id.product_tmpl_id == rec.origin_product_tmpl_id:
                raise ValidationError(_('A/B Panel Product Cannot be the same'))
